
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

  public function index(){//-->home_page  
      
      $this->layout();   

  }

  public function layout($site=Null){
    $param              = $this->uri->segment(4);     
    $data['categories'] = $this->mhome->get_categories();      //->sidebar page
    $data['content']    = $site;                             //->action pages               
    $data['footer']     = $this->mhome->get_footer();           //->footer page
    $data['frontend']    = base_url().'index.php/home/layout/';        
    $data['frontendimg'] = base_url().'public/frontend/images/';

    switch ($site){

    default             :$data['slideshow']     = $this->mhome->get_slideshow();//->home page
                         $data['about']         = $this->mhome->get_about();
                         $data['latproducts']   = $this->mhome->get_latproducts();  break;

    case 'about'        :$data['about']         = $this->mhome->get_about();        break;

    case 'categories'   :$data['content_cat']   = $this->mhome->content_categories($param);break;
    case 'news'         :
                        $this->load->library('pagination');
                         $config['base_url']         = base_url().'index.php/home/layout/news/';            
                         $config['total_rows']       = $this->mhome->get_total_rows_news();
                         //$config['use_page_numbers'] = TRUE;//hiển thị số trang đúng
                         $config['per_page']         = 3;  
                         $config['uri_segment']      = 4;                              
                         $this->pagination->initialize($config);                         
                         $data['news']          = $this->mhome->get_news($config['per_page'], $param); 
                         break; 


    case 'new_detail'   :$data['news']          = $this->mhome->get_news();         
                         $data['article']       = $this->mhome->get_article($param);break;
    case 'blog'         :$this->mhome->update_cate();
                         $this->load->library('pagination');
                         $config['base_url']         = base_url().'index.php/home/layout/blog/';            
                         $config['total_rows']       = $this->mhome->get_total_rows_cate();
                         //$config['use_page_numbers'] = TRUE;//hiển thị số trang đúng
                         $config['per_page']         = 2; 
                         $config['uri_segment']      = 4;                                                 
                         $this->pagination->initialize($config); 
                         $data['blog'] = $this->mhome->get_blog($config['per_page'], $param); break;
    case 'single_product':$data['single_product']= $this->mhome->get_product($param);break; 

    case 'products'     :$this->load->library('pagination');
                         $config['base_url']         = base_url().'index.php/home/layout/products/';            
                         $config['total_rows']       = $this->mhome->get_total_rows();
                         //$config['use_page_numbers'] = TRUE;//hiển thị số trang đúng
                         $config['per_page']         = 6;  
                         $config['uri_segment']      = 4;                              
                         $this->pagination->initialize($config); 
                         $data['products'] = $this->mhome->get_all_product($config['per_page'], $param);
                         break;

    }       
    
    if($site==Null){
      $this->load->view('frontend/home',$data);
    }
    else{
    $this->load->view('frontend/index', $data);
    }

  }  

   
}

/* End of file Home.php */
/* Location: ./application/controllers/Home.php */

